﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include"qlabel.h"
#include"qtimer.h"
#include"qwidget.h"
#include"QHBoxLayout"
#include"qpushbutton.h"
#include"matrixcontrolform.h"
#include"matrixmenuform.h"
#include "domainobject.h"
#include"actioncontrol.h"

namespace Ui {
class MainWindow;
}
typedef struct PDState{
        QLabel* p_icon;
        QLabel* p_state;
        QLabel *p_num;
        QLabel *p_lable;
        QWidget* p_widget;
        QHBoxLayout* p_HLayout;


}DState;
//鼠标移动地图风机图标menu
typedef struct PDMapNums{

        QPushButton* p_wind;
        QPushButton *p_electricity;
        QPushButton *p_power;

        QLabel * p_winds[3];
        QLabel * p_electricitys[3];
        QLabel * p_powers[3];
        QWidget* p_widget;
        QVBoxLayout* p_VLayout;
        QHBoxLayout* p_HLayouts[3];


}DMapNums;

//鼠标移动矩阵menu
typedef struct PDMatrixmenu{

        QPushButton* p_start;
        QPushButton *p_stop;

          QPushButton *p_Fuwei;//复位
           QPushButton *p_weihu;//维护
           QPushButton *p_noWeihu;//取消维护


        QLabel * p_news;

        QWidget* p_widget;
        QVBoxLayout* p_VLayout;
        QHBoxLayout* p_HLayouts;


}DDMatrixmenu;

typedef struct PDTopLeftState{
        QLabel* p_state;
        QLabel *p_num;
        QLabel *p_lable;
        QHBoxLayout* p_HLayout;


}DTopLeftState;

typedef struct PDMapState{
        QLabel* p_fengjiIcon;
         QLabel *p_name;

}DMapState;

typedef struct PDWindFieldProgress{
        QLabel* p_progress;
         QLabel *p_num;

}DWindFieldProgress;

typedef struct PDMatrixTop{
        QLabel* p_name[7];
         QLabel *p_num[7];
         QLabel *p_unit[7];
         QLabel * p_lableSpace;
         QSpacerItem * p_SpacerItem;
         QWidget * p_widget;
         QLabel * p_state[9];
         QHBoxLayout* p_HLayout;
         QVBoxLayout* p_VLayout;

}DMatrixTop;
typedef struct PDMatrixFengChang{
    QLabel* p_name[7];
     QLabel *p_num[7];
     QLabel *p_unit[7];
     QSpacerItem * p_SpacerItem;
     QLabel * p_state[9];
   //  QLabel * p_spacelable;

     QVector<QLabel*> v_fengji;
     QStringList FJnames;
     QStringList FJpowers;
     QStringList FJwinds;
      QStringList FJstates;
     QLabel * p_fengChang;
     QGridLayout *p_gridLayout;
     QWidget * p_widget;

     QHBoxLayout* p_HLayout;
     QVBoxLayout* p_VLayout;

     QStringList currentStyles;

     QString p_id;

     QVector<DomainObjectTurbine*> DomainObjectTurbines_One;//控制单个风机

}DMatrixFengChang;

typedef struct PDMatrixId{
   QStringList p_fengchangList;
   QString p_id;
   QVector<int> p_fengjiCount;

}DMatrixId;
typedef struct PDMatrixShengFen{
      QVector<DMatrixFengChang*> v_matrixFengChang;

}DMatrixShengFen;

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    void changeEvent(QEvent * e);
    void setStates();
     void setStates_Host();//切换界面添加 
       void setStates_Matrix(int index);//切换界面添加

    void setMatrixFengchang();
    void clearWidgets(int index);

    void setMatrixNames();//设置风机名
     void setMatrixNums();//设置风机数

   bool eventFilter(QObject *target, QEvent *e); // 重定义。事件过滤器

   int getMatrixTopFengJiCount(int pageId);
   void setMatrixTopStates(int pageId,QList<int> FengChangs);




signals:
    void sendMatrixFJEnter(int row,int index);  //进入风机发送信息菜单
    void setFengChangFJName(int FengcChang,int index,QString name);
    void setFengChangFJNums(int FengcChang,int index,QString wind,QString power,QString state);
    void setFengChangFJTops(int FengChang,QString windAve,QString powerCount,QList<int>states);

    void setMatrixTops(QList<int> FengChangs,QString windCount,QString powerCount);

private slots:

    void time_end();
    void time_update();

    void showWindowMax();

    void on_hostButton_clicked();

    void on_matrixButton_clicked();

    void on_parameterButton_clicked();

    void on_controlButton_clicked();

    void on_mainParameterButton_clicked();

    void on_searchButton_clicked();

    void on_manageButton_clicked();

    void on_boosterButton_clicked();



    void on_all_Button_clicked();

    void on_liaoNing_Button_clicked();

    void on_jiLin_Button_clicked();

    void on_heiLongJiang_Button_clicked();

    void on_mengDong_Button_clicked();

    void on_all_Button_2_clicked();

    void on_liaoNing_Button_2_clicked();

    void on_jiLin_Button_2_clicked();

    void on_heiLongJiang_Button_2_clicked();

    void on_mengDong_Button_2_clicked();

    void on_stackedWidget_2_customContextMenuRequested(const QPoint &pos);

    void on_exit_Button_clicked();

    void show_menu(int row,int index);//显示矩阵菜单

    void setFengChangFjName_Slots(int Fengchang,int index,QString name);
      void setFengChangFjNums_Slots(int Fengchang,int index,QString wind,QString power,QString state);
      void setFengChangFjTops_Slots(int Fengchang,QString windAve,QString powerCount,QList<int>states);
       void setMatrixTops_Slots(QList<int> FengChangs,QString windCount,QString powerCount);

      void on_pushButton_clicked();

      void menuStart();
      void menuStop();
      void menuReset();
      void menuRepair();
      void menuUnrepair();


private:
    Ui::MainWindow *ui;

    QLabel * p_topMapNumsHide;
    QLabel * p_lable[10];

    DState* p_state[7];
    DTopLeftState * p_topleftState[8];

    DMapState* p_mapState[8];

    DWindFieldProgress* p_windFieldProgress[8];


    QVector<DMatrixId*> p_matrixId;


    DMatrixTop * p_matrixTop;
    QTimer *timer =new QTimer(this);
    int timeNum=0;
    QTimer *timer2 =new QTimer(this);
    int timeNum2=0;

     QWidget* p_topleftwidget;
     QLabel * p_topleftlable;
     QVBoxLayout* p_VTopleftLayout;
     QLabel * p_navigationlable;//导航分割

     QWidget* p_toprightwidget;
     QLabel * p_toprightHlable;
     QLabel * p_toprightVlable;
     QLabel * p_toprightPowerlable;
      QLabel * p_toprightWindlable;

      QLabel* p_icon[7];

        QVBoxLayout* p_VLayout;
     QVector<DMatrixFengChang*> v_matrixFengChang;
    QSpacerItem *p_verticalSpacerMatrix;//矩阵Spacer
  PDMapNums *p_mapNums;

  QWidget *p_clickMenuWidget;
  PDMatrixmenu *p_matrixmenu;

  MatrixmenuForm * p_matrixmenuForm;
  // QMenu * p_menu;
bool menuFlag=false;//鼠标是否隐藏
bool menuEnterFlag=false;//鼠标是否进入菜单
  bool timeStart_falg=false;//定时器是否启动
  bool matriFJrightClicked_falg=false;//矩阵风机右键点击判断
 bool menuHideFirst=false;//矩阵菜单第一次隐藏

  MatrixControlForm *F_matrixControlForm;//矩阵全场控界面

  QWidget * LayoutWidget;//矩阵单元

//QVector<DMatrixShengFen*> v_matrixShengFen;

   int matrixmenu_row=0,matrixmenu_index=0;
   int deskWidth=0,deskHeight=0;

   bool enter=false;

   DomainObject* domainObject;
   QVector<DomainObject*> domainObjects;
    QVector<DomainObject*> v_domainObjects1;



    QStringList FJStateList;

     ActionControl * actionControl;

    QVector<int> FengChangIdRevices;

    QVector<double> topMatrixStates;

    QVector<int> pageFengChangCounts;





};

#endif // MAINWINDOW_H
